/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ticks.chromedome.subsystems;

import edu.wpi.first.wpilibj.DigitalInput;
import edu.wpi.first.wpilibj.SpeedController;
import edu.wpi.first.wpilibj.Victor;
import edu.wpi.first.wpilibj.command.Subsystem;
import ticks.chromedome.RobotMap;

/**
 *
 * @author Jared
 */
public class Turret extends Subsystem {
    private static Turret instance = null;
    private SpeedController turret_motor;
    private DigitalInput turret_left_limit;
    private DigitalInput turret_right_limit;
    // Put methods for controlling this subsystem
    // here. Call these from Commands.
    //rotate left positive
    
    public static Turret getInstance(){
        if(instance==null){
            instance= new Turret();
        }
        return instance;
    }
    private Turret(){
        turret_motor = new Victor(RobotMap.TURRET_MOTOR);
        turret_left_limit = new DigitalInput(RobotMap.TURRET_LEFT_LIMIT);
        turret_right_limit = new DigitalInput(RobotMap.TURRET_RIGHT_LIMIT);
    }
    
    public void setTurretMotorSpeed(double speed){
        if((speed>0 && turret_left_limit.get())||(speed<0 && turret_right_limit.get())){
            turret_motor.set(0);
        }
        else{
            turret_motor.set(speed);
        }
        
    }

    public void initDefaultCommand() {
        // Set the default command for a subsystem here.
        //setDefaultCommand(new MySpecialCommand());
    }
}
